package com.objcat.servicesecurity.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.objcat.servicesecurity.entity.po.UserPo;
import com.objcat.servicesecurity.entity.po.UserRolePo;
import com.objcat.servicesecurity.mapper.UserRoleMapper;
import com.objcat.servicesecurity.service.UserRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author misheep
 * @since 2020-07-29
 */
@Slf4j
@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRolePo> implements UserRoleService {

    @Autowired
    private UserRoleMapper userRoleMapper;
    /**
     * 获取用户角色关联
     * @param userPo
     * @return
     */
    @Override
    public UserRolePo getUserRole(UserPo userPo) {
        QueryWrapper<UserRolePo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",userPo.getUserId());
        return  userRoleMapper.selectOne(queryWrapper);
    }
}
